package com.da.web.dorm_look.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.da.web.dorm_look.entity.DormLook;
import com.da.web.dorm_look.entity.LookParm;
import com.da.web.dorm_look.mapper.DormLookMapper;
import com.da.web.dorm_look.service.DormLookService;
import org.springframework.stereotype.Service;

/**
 * @author da
 * @time 2023/12/15 上午 11:33
 */
@Service
public class DormLookServiceImpl extends ServiceImpl<DormLookMapper, DormLook> implements DormLookService {
    @Override
    public IPage<DormLook> pageList(LookParm parm) {
        IPage<DormLook> page = new Page<>(parm.getCurrentPage(), parm.getPageSize());
        QueryWrapper<DormLook> query = new QueryWrapper<>();
        if (StrUtil.isNotEmpty(parm.getLookRoom())) {
            query.lambda().like(DormLook::getLookRoom, parm.getLookRoom());
        }
        if (StrUtil.isNotEmpty(parm.getUserName())) {
            query.lambda().like(DormLook::getUserName, parm.getUserName());
        }
        return this.page(page, query);
    }
}
